package com.atguigu.gmall.product;

import com.atguigu.gmall.model.list.SearchParam;

import java.lang.reflect.Field;

/**
 * @author 李旭
 * @date 2021/10/16 11:10
 * @Description:
 */
public class ClassDemo {

    public static void main(String[] args) {
        SearchParam searchParam = new SearchParam();
        searchParam.setKeyword("手机");
        searchParam.setTrademark("1:苹果");
        String[] p = {"1:4G:内存","2:3000~4500:价格"};
        searchParam.setProps(p);

        Field[] fields = searchParam.getClass().getDeclaredFields();
        for (Field field : fields) {
            String name = field.getName();
            field.setAccessible(true);

            Object o = null;
            try {
                o = field.get(searchParam);
                boolean array = o.getClass().isArray();//判断是否是数组
                System.out.println(name+"是否是数组" + array);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            System.out.println();
            System.out.println("属性名 = " + name+"属性值 = " + o);
        }
    }
}
